package mainWindow;

import java.awt.*;

import javax.swing.ImageIcon;
import javax.swing.JTabbedPane;
import DataBase.Word;

/**
 * @author AI Wei
 *
 */

@SuppressWarnings("serial")
public class LeftPanel extends JTabbedPane implements ChangeStyle
{
	public final static int INDEX = 0;
	public final static int HISTORY = 1;
	public final static int GUIDE = 2;
	
	public IndexPanel indexPanel;
	private HistoryPanel historyPanel;
	private GuidePanel guidePanel;
	
	
	public LeftPanel(){
		super(JTabbedPane.LEFT);
		this.setMaximumSize(new Dimension(400, 2000));
		this.setMinimumSize(new Dimension(300, 500));
		
		indexPanel = new IndexPanel();
		addTab(null, new ImageIcon("images/icons/dict.png"), indexPanel, "Index");
		historyPanel = new HistoryPanel();
		historyPanel.init();
		addTab(null, new ImageIcon("images/icons/history.png"), historyPanel, "History");	
		guidePanel = new GuidePanel();
		guidePanel.init();
		addTab(null, new ImageIcon("images/icons/guide.png"),guidePanel,"Guide");
		this.setPanel(INDEX);
		this.setEnabledAt(GUIDE, false);
		
	}
	public void closing()
	{
		historyPanel.saveFile();
	}
	public GuidePanel getGuidePanel()
	{
		return guidePanel;
	}
	public void addWord(Word word)
	{
		historyPanel.addWord(word.getWord());
	}
	public void setPanel(int selection)
	{
		switch (selection)
		{
		case INDEX:
			setSelectedComponent(indexPanel);
			break;
		case HISTORY:
			setSelectedComponent(historyPanel);
			break;
		case GUIDE:
			setEnabledAt(GUIDE,true);
			setSelectedComponent(guidePanel);
			break;
		default:;			
		}
	}
	
	public void changeStyle(int styleIdx) {
		setBackground(null);
		setOpaque(false);
		historyPanel.changeStyle(styleIdx);
		indexPanel.changeStyle(styleIdx);
		guidePanel.changeStyle(styleIdx);
	}
}
